<template>
	<view class="box">
		<view class="top">
			<view class="text-top">
				Voyaged Zero
			</view>
			<view class="text-down">
				Find the AR model of the Chinese herbal medicine you want
			</view>
		</view>
		<view v-for="(item, index) in data" :key="index" class="card">
			<transition name="card">
			<view class="card-content">
				<img class="cardImg" :src="item.img" alt="">
				<text class="text">{{item.name}}</text>
				<view class="cardInfo">
					{{item.info}}
				</view>
				<button class="buttonAr" @click.stop="jump(item.sceneId)">点击查看</button>
			</view>
			</transition>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: []
			};
		},
		methods: {
			// 发起请求
			getData() {
				uni.request({
					url: 'https://mock.apifox.cn/m2/2672959-0-default/81580837?apifoxApiId=81580837',
					method: 'GET',
					success: (res) => {
						console.log(res.data)
						this.data = res.data
					},
					fail: (err) => {
						console.log(err)
					}
				})
			},
			jump (sceneId) {
				wx.navigateTo({ url: `plugin://kivicube-slam/scene?id=${sceneId}` });
			}
		},
		mounted() {
			// 通过 URL 发送请求  
			this.getData()
		}
	}
</script>

<style scoped>
	.top {
		width: 100%;
		height: 420rpx;
		background-color: rgb(29, 185, 84);
		border-bottom-left-radius: 40upx;
		border-bottom-right-radius: 40upx;
		margin-bottom: 50upx;
	}
	.text-top {
		margin-left: 30upx;
		margin-top: 100upx;
		color: white;
		font-size: 60upx;
		font-family: 'Times New Roman', Times, serif
	}
	
	.text-down {
		margin-left: 30upx;
		margin-top: 20upx;
		color: white;
		font-size: 35upx;
		font-weight: 200;
	}
	
	.box {
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
	}

	.buttonAr {
		width: 200upx;
		height: 60upx;
		font-size: 28upx;
		background-color: rgb(29, 185, 84);
		color: white;
		text-align: center;
		line-height: 60upx;
	}

	.card {
		margin-bottom: 50upx;
		width: 450upx;
		height: 500upx;
		background-color: #FFF;
		border-radius: 16px;
		box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.card-content {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 24px;

	}

	.cardImg {
		width: 150upx;
		height: 150upx;
		border-radius: 50%;
		margin-bottom: 10upx;
	}

	.text {
		color: black;
		font-size: 40upx;
	}

	.cardInfo {
		margin-top: 10upx;
		width: 350upx;
		height: 130upx;
		overflow: hidden;
		text-overflow: ellipsis;
		font-size: 32upx;
	}
</style>